// Copyright (c)  YISH. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using NSQL.Sharpen;

namespace NSQL.Expressions.Functions
{
    public class DiffFunction : BaseExpression, IDiffFunction
    {
        public IDateTimeExpression Start { get; set; }
        public IDateTimeExpression End { get; set; }
        public ExtractType Type { get; set; }

        public DiffFunction(IDateTimeExpression start, IDateTimeExpression end, ExtractType type)
        {
            Start = start;
            End = end;
            Type = type;
        }
        public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.Visit(this);
        public override void Accept(IExpressionVisitor visitor) => visitor.Visit(this);
        public override bool IsValid => Start.IsValid && End.IsValid;
        protected override IExpression DeepCopy()
        {
            return new DiffFunction(Start.DeepClone(), End.DeepClone(), Type)
            {
                Tag = Tag
            };
        }
    }
}